package com.yusysqdy.gulimail.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: gulimail
 * @contact: qindy0116@126.com
 * @author: Mr.DYQin
 * @create: 2021-01-13 17:04
 **/

@Configuration
public class MyRedissonConfig {

    @Value("${ipAddr}")
    private String ipAddr;

    /**
     * 所有对Redisson的使用都是通过RedissonClient对象实现的
     * @return
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redisson() {
        Config config = new Config();
        // 创建单例模式的配置
        config.useSingleServer().setAddress("redis://" + ipAddr + ":6379");
        return Redisson.create(config);
    }

}
